<!DOCTYPE html>
<html>
	<head>
		<title>顾客减重排名表</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">
		<%include("/common/include.html"){}%>
	</head>
	<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<style type="text/css">
		.textbox{
			padding-right:0px;
			background:url("${cxt !}/sb/themes/insdep/images/combo_arrow.png") no-repeat scroll right center transparent;
		} 
	</style>
	<script type="text/javascript">
		$(function() {
			var $form_div = $("#queryByCustom div");
			winResize($form_div);
			$(window).resize(function(){//当调整浏览器窗口的大小时，发生 resize 事件
				winResize($form_div);
			});
		})
		$(document).ready(function () {	
			var url='/customerForProductList/queryproductdata';
			var result = common_ajax.ajaxFunc(url,null,"json");
			var columnsAll = new Array();
			var columnsAll2 = new Array();
			columnsAll.push({field:'name',title:'名称',width:60,align:'center',rowspan:2});
			columnsAll.push({field:'jdrq',title:'首次到店日期',width:100,align:'center',rowspan:2});
			columnsAll.push({field:'weight',title:'首次到店体重',width:64,align:'center',rowspan:2,
				formatter: function(value,row,index){
					if(row.weight != null){
						var a=row.weight+'斤';
						return  a;
					}
				}});
			columnsAll.push({field:'std_weight',title:'标准体重',width:64,align:'center',rowspan:2,
				formatter: function(value,row,index){
					if(row.std_weight != null){
						var a=row.std_weight+'斤';
						return  a;
					}
				}});
			columnsAll.push({field:'delweight',title:'应减体重',width:64,align:'center',rowspan:2,
				formatter: function(value,row,index){
					if(row.delweight != null){
						var a=row.delweight+'斤';
						return  a;
					}
				}});
			columnsAll.push({field:'treatment',title:'疗程数',width:64,align:'center',rowspan:2});
			columnsAll.push({field:'count',title:'当月产品使用次数',width:120,align:'center',rowspan:2,sortable:true});
			columnsAll.push({field:'count2',title:'产品累计使用次数',width:120,align:'center',rowspan:2,sortable:true});
			for(var i =0;i<result.length;i++){
				columnsAll.push({field:'qwer',title:result[i].chanplx,width:120,align:'center',colspan:2});
			}
			columnsAll.push({field:'sumprice',title:'合计',width:60,align:'center',rowspan:2,sortable:true});
			columnsAll.push({field:'bili',title:'减重/(精油+紧肤膏)',width:120,align:'center',rowspan:2,sortable:true});
			columnsAll.push({field:'isuseproduct',title:'是否使用过产品',width:120,align:'center',rowspan:2,sortable:true});
			for(var i =0;i<result.length;i++){
				columnsAll2.push({field:result[i].typeids+'number',title:'数量',width:60,align:'center'});
				columnsAll2.push({field:result[i].typeids+'price',title:'金额',width:60,align:'center'});
			}
			$('#datagrid').datagrid({
				queryParams: {
					'organIdsEmployee': $("#organIdsEmployee").val(),
					'arrivedMinDate': $("#arrivedMinDate").val(),
				},
				singleSelect: true,
				rownumbers: true, //显示序号
				remoteSort:false,
				url:'customerForProductList/customerDataQuery',
				collapsible: true,
				columns:[columnsAll,columnsAll2],
			});
		})
		function queryCustomer(){
			var url='/customerForProductList/queryproductdata';
			var result = common_ajax.ajaxFunc(url,null,"json");
			var columnsAll = new Array();
			var columnsAll2 = new Array();
			columnsAll.push({field:'name',title:'名称',width:60,align:'center',rowspan:2});
			columnsAll.push({field:'jdrq',title:'首次到店日期',width:100,align:'center',rowspan:2});
			columnsAll.push({field:'weight',title:'首次到店体重',width:64,align:'center',rowspan:2,
				formatter: function(value,row,index){
					if(row.weight != null){
						var a=row.weight+'斤';
						return  a;
					}
				}});
			columnsAll.push({field:'std_weight',title:'标准体重',width:64,align:'center',rowspan:2,
				formatter: function(value,row,index){
					if(row.std_weight != null){
						var a=row.std_weight+'斤';
						return  a;
					}
				}});
			columnsAll.push({field:'delweight',title:'应减体重',width:64,align:'center',rowspan:2,
				formatter: function(value,row,index){
					if(row.delweight != null){
						var a=row.delweight+'斤';
						return  a;
					}
				}});
			columnsAll.push({field:'treatment',title:'疗程数',width:64,align:'center',rowspan:2});
			columnsAll.push({field:'count',title:'当月产品使用次数',width:120,align:'center',rowspan:2,sortable:true});
			columnsAll.push({field:'count2',title:'产品累计使用次数',width:120,align:'center',rowspan:2,sortable:true});
			for(var i =0;i<result.length;i++){
				columnsAll.push({field:'qwer',title:result[i].chanplx,width:120,align:'center',colspan:2});
			}
			columnsAll.push({field:'sumprice',title:'合计',width:60,align:'center',rowspan:2,sortable:true});
			columnsAll.push({field:'bili',title:'减重/(精油+紧肤膏)',width:120,align:'center',rowspan:2,sortable:true});
			columnsAll.push({field:'isuseproduct',title:'是否使用过产品',width:120,align:'center',rowspan:2,sortable:true});
			for(var i =0;i<result.length;i++){
				columnsAll2.push({field:result[i].typeids+'number',title:'数量',width:60,align:'center'});
				columnsAll2.push({field:result[i].typeids+'price',title:'金额',width:60,align:'center'});
			}
			
			$('#datagrid').datagrid({
				queryParams: {
					'organIdsEmployee': $("#organIdsEmployee").val(),
					'arrivedMinDate': $("#arrivedMinDate").val(),
				},
				singleSelect: true,
				rownumbers: true, //显示序号
				remoteSort:false,
				url:'customerForProductList/customerDataQuery',
				collapsible: true,
				columns:[columnsAll,columnsAll2],
			});	
		};
		function queryCustomerExcel(){
			var organIdsEmployee = $("#organIdsEmployee").val();
			var arrivedMinDate = $("#arrivedMinDate").val();
			var url = 
			"${cxt!}/customerForProductList/excel?&arrivedMinDate="
			+arrivedMinDate+
			"&organIdsEmployee="
			+organIdsEmployee;
			window.location.href = url;
		}
	</script>
	<body class="easyui-layout">
		<div data-options="region:'north',split: true,title:'快速查询'" style="height:200px;padding:10px;">				
			<form id="queryByCustom"  method="post">
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">店面名称：</label>
					<input id="organEmployee" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="showMenuEmployee(); return false;" class="textbox" value="${curOrgan.name! }"/>
					<input name="selOrganIds" id="organIdsEmployee" type="hidden" value="${curOrgan.ids! }">
				</div>
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">日期：</label>
					<input name="_query.arrivedMinDate" id="arrivedMinDate" value="${date()}" class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center"
						data-options="editable: false"/>
				</div>
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">搜索</label>
					<a href="#" onclick="queryCustomer()" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="height:32px;width:212px;text-align:center">搜索</a>
				</div>
				<div style="margin-bottom: 10px;float:left;">
					<label class="label-top" style="width: 100%; display: block;">导出</label>
					<a href="#" onclick="queryCustomerExcel()" class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:212px">导出</a>
				</div>
			</form>
		</div>
		<div data-options="region:'center'" style="overflow-x:hidden;">
			<table id="datagrid" style="width: 100%; height: 100%;"></table>
		</div>
		<div id="menuContentEmployee" class="menuContentEmployee" style="display: none; position: absolute;z-index: 10;">
			<ul id="organSelectTreeEmployee" class="ztree" style="margin-top: 0;width: 200px;"></ul>
		</div>
		<!-- 店员标签门店树形图 -->
		<script type="text/javascript">
			var organIdsEmployee=$('#organIdsEmployee').val();
			var settingEmployee = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					otherParam : {
						"organIds" : organIdsEmployee
					},
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClickEmployee,
					onAsyncSuccess : organTreeOnAsyncSuccessEmployee
				}
			};
			var flagEmployee=0;//只初始化一次标识
			function organTreeOnAsyncSuccessEmployee(event, treeId, msg) {
				if(flagEmployee == 0){
					var organTree = $.fn.zTree.getZTreeObj("organSelectTreeEmployee");
					var nodes = organTree.getNodes();
					flagEmployee = 1;
				}
			}
			function onClickEmployee(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("organSelectTreeEmployee");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
					}
				}
				var cityObj = $("#organEmployee");
				cityObj.attr("value", path);
				$("#organIdsEmployee").attr("value", treeNode.id);
				hideMenuEmployee();
			}
			function showMenuEmployee() {
				var cityObj = $("#organEmployee");
				var cityOffset = $("#organEmployee").offset();
				$("#menuContentEmployee").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
				$("body").bind("mousedown", onBodyDownEmployee);
			}
			function hideMenuEmployee() {
				$("#menuContentEmployee").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDownEmployee);
			}
			function onBodyDownEmployee(event) {
				if (!(event.target.id == "menuBtn" || event.target.id  == "menuContentEmployee" || $(event.target).parents("#menuContentEmployee").length > 0)){
					hideMenuEmployee();
				}
			}
			$.fn.zTree.init($("#organSelectTreeEmployee"), settingEmployee);
		</script>
	</body>
</html>
